home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / C de cerca / Codewarrior Lite / MacOS Support / Headers / ANSI Headers / sstream < prev    next >
Text File  |  1995-12-29  |  2KB  |  84 lines

  1. // sstream standard header
  2. #ifndef _SSTREAM_
  3. #define _SSTREAM_
  4. #include <string>
  5. #include <strstream>
  6.  
  7. #if __MWERKS__
  8. #pragma options align=mac68k
  9.  
  10. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  11. #pragma import on
  12. #endif
  13. #endif
  14.  
  15.         // class stringbuf
  16. class stringbuf : public strstreambuf {
  17. public:
  18.     stringbuf(ios::openmode _W = ios::in | ios::out)
  19.         : strstreambuf(0, 0, 0, _Mode(_W)) {}
  20.     stringbuf(const string& _S,
  21.         ios::openmode _W = ios::in | ios::out)
  22.         : strstreambuf((char *)_S.c_str(), _S.length(), 0,
  23.             _Mode(_W)) {}
  24.     virtual ~stringbuf();
  25.     string str() const;
  26.     void str(const string& _S);
  27. protected:
  28.     _Strstate _Mode(ios::openmode);
  29.     };
  30.         // class istrstream
  31. class istringstream : public istream {
  32. public:
  33.     istringstream(openmode _W = in)
  34.         : ios(&_Sb), istream(&_Sb), _Sb(_W) {}
  35.     istringstream(const string& _S, openmode _W = in)
  36.         : ios(&_Sb), istream(&_Sb), _Sb(_S, _W) {}
  37.     virtual ~istringstream();
  38.     stringbuf *rdbuf() const
  39.         {return ((stringbuf *)&_Sb); }
  40.     string str() const
  41.         {return (_Sb.str()); }
  42.     void str(const string& _S)
  43.         {_Sb.str(_S); }
  44. private:
  45.     stringbuf _Sb;
  46.     };
  47.         // class ostrstream
  48. class ostringstream : public ostream {
  49. public:
  50.     ostringstream(openmode _W = out)
  51.         : ios(&_Sb), ostream(&_Sb), _Sb(_W) {}
  52.     ostringstream(const string& _S, openmode _W = out)
  53.         : ios(&_Sb), ostream(&_Sb), _Sb(_S, _W) {}
  54.     virtual ~ostringstream();
  55.     stringbuf *rdbuf() const
  56.         {return ((stringbuf *)&_Sb); }
  57.     string str() const
  58.         {return (_Sb.str()); }
  59.     void str(const string& _S)
  60.         {_Sb.str(_S); }
  61. private:
  62.     stringbuf _Sb;
  63.     };
  64.  
  65. #if __MWERKS__
  66. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  67. #pragma import reset
  68. #endif
  69.  
  70. #pragma options align=reset
  71. #endif
  72.  
  73. #endif
  74.  
  75. /*
  76.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  77.  * Consult your license regarding permissions and restrictions.
  78.  */
  79.  
  80. /* Change log:
  81.  *94June04 PlumHall baseline
  82.  *94Oct07 Inserted MW changes.
  83.  */
  84.